﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers; 
namespace WPFExcelReport
{
    public partial class TDVK02
    { 
        public TDVK02()
        {

            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKKOPF();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["VKKMANDANT"] = app.Mandant;
            SResult = TMV.QVKK99(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }
        public void ResetSeq(object sender, RoutedEventArgs e)
        {
            //VK04.VK05,VK06(地址),VKZUAB,VVT,VR05,VRK,AB52,WDECK,销售单相关WB14，销售点流水号为1
            dwData = TBMain.NewRow();
            dwData["VKKMANDANT"] = app.Mandant;
            dwData["VKKAUFKRS"] = KRS;
            TMV.DeleteVKKOPF(dwData, 0);
            dwData = TMV.VKP.TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPAUFKRS"] = KRS;
            TMV.VKP.DeleteVKPOS(dwData, 0);

            dwData = TMV.VKD.TBMain.NewRow();
            dwData["VKAMANDANT"] = app.Mandant;
            dwData["VKAAUFKRS"] = KRS;
            dwData["VKASA"] = " ";
            TMV.VKD.DeleteVKADR(dwData, 0);

            dwData = TMV.VZB.TBMain.NewRow();
            dwData["VKZMANDANT"] = app.Mandant;
            dwData["VKZAUFKRS"] = KRS;
            dwData["VKZSA"] = "VK";
            TMV.VZB.DeleteVKZUAB(dwData, 0);

            dwData = TMV.VZB.TBMain.NewRow();
            dwData["VKZMANDANT"] = app.Mandant;
            dwData["VKZAUFKRS"] = KRS;
            dwData["VKZSA"] = " ";
            TMV.VZB.DeleteVKZUAB(dwData, 0);

            dwData = TMV.VVT.TBMain.NewRow();
            dwData["VVTMANDANT"] = app.Mandant;
            dwData["VVTAUFTYP"] = "K";
            dwData["VVTAUFKRS"] = KRS;
            TMV.VVT.DeleteVVTLIEF(dwData, 0);

            dwData = TMV.VRP.TBMain.NewRow();
            dwData["VRPMANDANT"] = app.Mandant;
            dwData["VRPAUFKRS"] = KRS;
            dwData["VRPSTATIST"] = "K";
            TMV.VRP.DeleteVRPOS(dwData, 0);

            dwData = TMV.VRK.TBMain.NewRow();
            dwData["VRKMANDANT"] = app.Mandant;
            dwData["VRKZESSION"] = "K";
            dwData["VRKVERBNR"] = " AND VRKVERBNR LIKE '" + KRS + "%'";
            TMV.VRK.DeleteVRKOPF(dwData, 0);

            dwData = TMV.MUX.TBMain.NewRow();
            dwData["ABAMANDANT"] = app.Mandant;
            dwData["ABAVKAUFKRS"] = KRS;
            dwData["ABAVKAUFTYP"] = "K";
            TMV.MUX.DeleteABAUFM(dwData, 0);

            dwData = TMV.VWD.TBMain.NewRow();
            dwData["WDMANDANT"] = app.Mandant;
            dwData["WDAUFKRS"] = KRS;
            dwData["WDSA"] = "K";
            TMV.VWD.DeleteWDECK(dwData, 0);

            dwData = TMV.WBW.TBMain.NewRow();
            dwData["WBEWMANDANT"] = app.Mandant;
            dwData["WBEWAUFTYP"] = "K";
            dwData["WBEWAUFKRS"] = KRS;
            TMV.WBW.DeleteICC_WBBEW(dwData, 0);
            TMV.WBWT.DeleteWBBEW(dwData, 0);
            VSDDAT.SD22.RESETSEQ("0022", KRS, "VKAUFTR", "1");

        }
    }
}
